package com.gaojinqi.order.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @author gaojinqi
 * @date 2019/5/26 22:35
 */
@Component
@EnableBinding({StreamClient.class})
@Slf4j
public class StreamReceiver {

    @StreamListener(StreamClient.INPUT)
    public void processInput(String message) {
        log.info("StreamReceiver：{}", message);
        log.info("接受到 OUTPUT 返回的消息：{}", message);
    }

    @StreamListener(StreamClient.OUTPUT)
    @SendTo(StreamClient.INPUT)
    public String process(String message) {
        log.info("StreamReceiver：{}", message);
        return "已接收消息：" + message;
    }
}
